package com.cskaoyan.controller.wx.order;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.GenericData;
import com.cskaoyan.bean.wx.order.AfterSaleOrderDetail;
import com.cskaoyan.bean.wx.order.OrderDetailAfterSale;
import com.cskaoyan.config.exception.LoginAuthenException;
import com.cskaoyan.service.wx.AfterSaleService;
import com.cskaoyan.service.wx.WxOrderService;
import com.cskaoyan.util.UserIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LiangRuiJiang
 * @since 2022/06/09  11:35
 */
@RestController
@RequestMapping("wx/aftersale")
public class AfterSaleController {

    @Autowired
    AfterSaleService afterSaleService;

    @RequestMapping("detail")
    public BaseRespVo detail(Integer orderId){
        // wxOrderSer
        OrderDetailAfterSale orderDetailAfterSale = afterSaleService.queryOrderDetailAfterSale(orderId);
        return BaseRespVo.okAndSuccess(orderDetailAfterSale);
    }

    @PostMapping("submit")
    public BaseRespVo submit(@RequestBody() OrderAfterSaleSubmitBo orderAfterSaleSubmitBo) throws LoginAuthenException {
        Integer userId = UserIdUtil.getUserIdFromSubjectThrowException();
        afterSaleService.submitAfterSaleReply(orderAfterSaleSubmitBo,userId);
        return BaseRespVo.ok();
    }


}
